package cqie.edu.bootexperiment3;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import cqie.edu.bootexperiment3.domain.TCustomer;
import cqie.edu.bootexperiment3.domain.TOrder;
import cqie.edu.bootexperiment3.mapper.TCustomerMapper;
import cqie.edu.bootexperiment3.mapper.TOrderMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.sql.Wrapper;
import java.util.List;

@SpringBootTest
public class test_query {

    @Autowired
    TOrderMapper tOrderMapper;

    @Autowired
    TCustomerMapper tCustomerMapper;

    @Test
    public void test_query() {
//        229970608 何慧君
        List<TOrder> tOrders = tOrderMapper.selectOrders();
        for (TOrder tOrder : tOrders) {
            System.out.println(tOrder);
        }
    }


    @Test
    public void test_mp_query1() {
        //229970608 何慧君
        //构建条件构造器
        QueryWrapper<TCustomer> qw = new QueryWrapper<>();
        qw.lambda().like(TCustomer::getUsername, "张");
        //利用mp内置方法完成查询（继承至BaseMapper）
        List<TCustomer> tCustomers = tCustomerMapper.selectList(qw);
        for (TCustomer tCustomer : tCustomers) {
            System.out.println(tCustomer);
        }
    }

}
